1. Field of the Invention
This invention relates to coding and decoding devices for effecting high-compression coding of image data.
2. Description of the Related Art
When an image signal is stored into a memory device such as a memory card, magnetic card or magnetic tape as digital data, or when an image signal is transmitted or received by means of an image communication system, the amount of data to be handled is extremely large so that data of the image signal must be subjected to some high-efficiency compression in order to store or receive/transmit a large number of frame images with a limited memory capacity.
Further, time taken for effecting the data recording/reproducing process must be made short in a digital electronic still camera or the like. The same requirement must be met when moving picture images are recorded in a digital VTR (video tape recorder), digital animation film or the like. That is, time required for effecting the data recording/reproducing process must be made short irrespective of still picture images or moving picture images.
A coding method made up by combining the orthogonal transform coding and the variable length coding is widely known as a high-efficiency image data compression system. A typical example of the method is studied for the still image coding international standardization. This method is schematically explained below.
First, image data is divided into blocks of preset size and then subjected to the 2-dimensional DCT (discrete cosine transform) for the orthogonal transform for each of the divided blocks. Then, the linear quantization is effected according to the respective frequency components and the thus quantized values are subjected to the Huffman coding for the variable length coding. At this time, the DC component is processed such that a difference between the DC component of a block and the DC component of the neighboring block is subjected to the Huffman coding. The AC component is subjected to the 2-dimensional Huffman coding by effecting a so-called zig-zag scanning in a frequency range from the low-frequency component to the high-frequency component and detecting the number of consecutive invalid (the value is 0) components and the value of the valid component succeeding the sequence of invalid components.
The above operation is described in detail with reference to FIG. 8. First, as shown in (a), image data of one frame is divided into blocks of preset size (for example, blocks A, B, C, . . . of 8.times.8 pixels) and then subjected to the 2-dimensional DCT (discrete cosine transform) for the orthogonal transform for each of the divided blocks and sequentially stored on 8.times.8 matrices.
When viewing the image data in the 2-dimensional plane, it contains the spatial frequency which is frequency data corresponding to the distribution of light and shade information items. Therefore, by effecting the above DCT, the image data is converted into the DC component DC and AC component AC, and data indicating the value of the DC component DC is stored on the origin (0, 0) of the 8.times.8 matrix, data indicating the maximum frequency value of the AC component AC in the abscissa direction is stored on the position (0, 7), data indicating the maximum frequency value of the AC component AC in the ordinate direction is stored on the position (7, 0), and data indicating the maximum frequency value of the AC component AC in the oblique direction is stored on the position (7, 7). In each of the intermediate positions of the matrix, frequency data having a higher frequency component is stored as the coordinate position thereof becomes farther from the origin in the above directions.
Next, the linear quantization for each frequency component is effected by dividing the stored data in each of the coordinate position of the matrix by the quantization width of each frequency component (c), and the thus quantized value is subjected to the Huffman coding for the variable length coding. At this time, the DC component DC is processed such that a difference between the DC component of a block and the DC component of the neighboring block is expressed by a group number (the number of an additional bit) and an additional bit, the group number is subjected to the Huffman coding, and the coding word derived by effecting the Huffman coding and the additional bit are combined to construct coding data (d1, d2, e1, e2).
The AC component AC of a valid factor (the value is not "0") is also expressed by a group number and an additional bit. The AC component AC is subjected to the 2-dimensional Huffman coding by effecting a so-called zig-zag scanning in a frequency range from the low-frequency component to the high-frequency component and detecting the number (the run number of "0") of consecutive invalid (the value is 0) components and a group number of the value of a valid component succeeding the sequence of invalid components, and the thus derived coding word and the additional bit are combined to construct coding data.
In the Huffman coding, data is coded to construct a code word by assigning a least number of data bits to those of the DC and AC frequency components which have the peak frequency of occurrence for each frame image in the data distribution, and assigning a larger number of data bits to the frequency components farther from the peak portion. The above operation is the basic part of the coding system.
With only the above basic part, the code amount becomes nonuniform for each image since the Huffman coding which is the variable length coding is used. Therefore, the inventors of this application proposed the following method as a method of controlling the code amount in the Japanese Patent Application No. 2-137222.
In the data compression system constructed by combining the orthogonal transform and the variable length coding, in order to control the generated code amount, an image signal stored in the memory is divided into blocks and subjected to the orthogonal transform for each of the divided blocks, and then the transformed output is quantized by use of a provisional quantization width, the quantized output is subjected to the variable length coding, the generated code amount for each block and the total generated code amount for the entire image are derived and a new quantization width is estimated from the provisional quantization width, the total generated code amount and a desired total code amount (first pass). After this, the image signal in the image memory is sequentially subjected to the block division, orthogonal transform, quantization and variable length coding by use of the new quantization width, and a code amount assigned for each block is derived based on the total generated code amount and the generated code amount for each block in the first pass and the desired total code amount. If the generated code amount of each block exceeds the code amount assigned to each block, the variable length coding is interrupted on the half way and the process for the next block is started (second pass). Thus, the above system is designed to control the code amount so that the total generated code amount of the entire image will not exceed the desired preset code amount.
As described before, it is desired that the image data compression can be effected with high efficiency in the case of the image recording and reception/transmission. In order to meet the above requirement, the above-described international standardization system is provided, and in this system, image data compression can be effected with high efficiency by use of a method which is a combination of the variable length coding and the orthogonal transform for each block, but since the data compression procedure is complicated, time for the process will become long. In general, since the processing time for the data compression varies in proportion to the number of pixels of an image, a fully satisfied result can be obtained in that the code amount can be made uniform by use of the system proposed in the Japanese Patent Application No. 2-137222 (corresponding to U.S. Pat. No. 5,073,820 issued Dec. 17, 1991) for attaining extremely high resolution, but since two passes are used for the coding, the processing time will be made further long. It is necessary to shorten the processing time from the viewpoint of the operability and power consumption in the image recording and transmission devices.